package aiyh.utils.httpUtil;

import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;

/**
 * IO流拓展工具类，补充IOUtils新版本中废弃的closeQuietly
 *
 * @author EBU7-dev1-ayh
 * @since 2021/08/30 17:56
 */
public class ExtendedIOUtils {

	public static void flush(Flushable... resources) throws IOException {
		int length = resources.length;
		for (int i = 0; i < length; ++i) {
			Flushable resource = resources[i];
			if (resource != null) {
				resource.flush();
			}
		}
	}

	public static void closeQuietly(Closeable... resources) {
		int length = resources.length;
		for (int i = 0; i < length; ++i) {
			Closeable resource = resources[i];
			if (resource != null) {
				try {
					resource.close();
				} catch (IOException e) {
					//ignore exception
				}
			}
		}
	}

}
